<?php
/**
 * Cust Return
 */
class CR extends AppModel {
    var $name = 'CR';

    var $useTable = 'cust_returns';

    const CUST_STOCK_OUT_TYPE = 'R';

    var $belongsTo = array('Product', 'CustProductSite',
        'CRH' => array(
            'foreignKey' => 'cust_return_head_id'
        ),
    );

    var $hasMany = array(
        'ProductSerial' => array(
            'foreignKey' => 'cust_stock_out_id',
            'conditions' => array(
                'cust_stock_out_type' => self::CUST_STOCK_OUT_TYPE
            )
        )
    );

    var $validate = array(
        'return_qty' => array(
            'rule' => 'numeric',
            'message' => 'Please input return qty.',
            'on' => 'create'
        ),
    );
}
?>
